# valid cache:when values
job1:
  script:
    - echo 'running job'
  cache:
    when: 'on_success'

job2:
  script:
    - echo 'running job'
  cache:
    when: 'on_failure'

job3:
  script:
    - echo 'running job'
  cache:
    when: 'always'

# valid cache:paths
cache-paths:
  script: echo "This job uses a cache."
  cache:
    key: binaries-cache
    paths:
      - binaries/*.apk
      - .config

# valid cache:key
cache-key-string:
  script: echo "This job uses a cache."
  cache:
    key: random-string
    paths:
      - binaries/

cache-key-string-with-dots:
  script: echo "This job uses a cache."
  cache:
    key: random-..string
    paths:
      - binaries/

cache-key-string-beginning-with-dot:
  script: echo "This job uses a cache."
  cache:
    key: .random-string
    paths:
      - binaries/

cache-key-string-ending-with-dot:
  script: echo "This job uses a cache."
  cache:
    key: random-string.
    paths:
      - binaries/

cache-key-predefined-variable:
  script: echo "This job uses a cache."
  cache:
    key: $CI_COMMIT_REF_SLUG
    paths:
      - binaries/

cache-key-combination:
  script: echo "This job uses a cache."
  cache:
    key: binaries-cache-$CI_COMMIT_REF_SLUG
    paths:
      - binaries/

# valid cache:key:files
cache-key-files:
  script: echo "This job uses a cache."
  cache:
    key:
      files:
        - Gemfile.lock
        - package.json
    paths:
      - vendor/ruby
      - node_modules

# valide cache:key:prefix
cache-key-prefix-string:
  script: echo "This job uses a cache."
  cache:
    key:
      files:
        - Gemfile.lock
      prefix: random-string
    paths:
      - binaries/

cache-key-prefix-predefined-variable:
  script: echo "This job uses a cache."
  cache:
    key:
      files:
        - Gemfile.lock
      prefix: $CI_JOB_NAME
    paths:
      - binaries/

cache-key-prefix-combination:
  script: echo "This job uses a cache."
  cache:
    key:
      files:
        - Gemfile.lock
      prefix: binaries-cache-$CI_JOB_NAME
    paths:
      - binaries/

# valid cache:untracked
cache-untracked-true:
  script: test
  cache:
    untracked: true

cache-untracked-false:
  script: test
  cache:
    untracked: false

# valid cache:policy
cache-policy-push:
  script: echo "This job uses a cache."
  cache:
    policy: push

cache-policy-pull:
  script: echo "This job uses a cache."
  cache:
    policy: pull

cache-no-policy:
  script: echo "This job uses a cache."
  cache:
    paths:
      - binaries/
